<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>用户推荐码列表</title>
    <link rel="stylesheet" type="text/css" th:href="@{/js/layui/css/layui.css}" media="all">
    <link rel="stylesheet" type="text/css" th:href="@{/css/fyn/style.css/}" media="all">
    <link rel="stylesheet" type="text/css" th:href="@{/css/fyn/my.css/}" media="all">
    <style>
        .layui-table-cell{
            display:table-cell;
            vertical-align: middle;
        }
        .fr .layui-input-inline{
            margin-right: 20px;
        }
    </style>
</head>
<body class="body">
<div class="my-btn-box layui-form">
    <span class="fr">
        <div class="layui-input-inline">
            <input type="text" autocomplete="off" name="recommendCode" placeholder="邀请码" class="layui-input height33">
        </div>
        <button class="layui-btn layui-btn-sm" id="search"><i class="layui-icon">&#xe615;</i>搜索</button>
    </span>
</div>

<!-- 表格 -->
<div id="dateTable" lay-filter="event"></div>
<div class="height50"></div>
<script th:src="@{/js/layui/layui.js}"></script>
<script th:src="@{/js/fyn/index.js}"></script>
<script th:src="@{/js/fyn/my.js}"></script>
<script type="text/javascript" th:src="@{/js/vip/vip_comm.js}"></script>
<script type="text/javascript" th:src="@{/js/vip/vip_table.js}"></script>
<script type="text/javascript" th:inline="javascript">

    // layui方法
    layui.use(['table', 'form', 'element', 'laypage', 'layer', 'vip_table'], function () {
        // 操作对象
        var form = layui.form
            , table = layui.table
            , layer = layui.layer
            , vipTable = layui.vip_table
            , $ = layui.jquery;

        var element = layui.element;

        // 表格渲染
        var tableIns = table.render({
            elem: '#dateTable'                  //指定原始表格元素选择器（推荐id选择器）
            , height: "full"    //容器高度
            // , skin: 'line'
            , even: 'true'
            , cols: [[                  //标题栏
                {field: 'codeLevel', title: '推荐码级别', minWidth: '100', sort: true, align: 'center', templet: function (d) {
                        return d.codeLevel == 1 ? '<button type="button" class="layui-btn layui-btn-sm layui-btn-danger">父级</button>'
                            : d.codeLevel == 0 ? '<button type="button" class="layui-btn layui-btn-sm layui-btn-warm">自己</button>'
                                : '<button type="button" class="layui-btn layui-btn-sm layui-btn-normal">子级</button>';
                }}
                ,{field: 'id', title: 'ID', minWidth: '100', sort: true, align: 'center'}
                ,{field: 'nick', title: '昵称', minWidth: '100', align: 'center'}
                , {
                    field: 'pName', title: '手机号', minWidth: '100', align: 'center', templet: function (d) {
                        return d.mobile == null ? '' : d.mobile;
                    }
                }
                , {field: 'ucode', title: '邀请码', minWidth: '100', align: 'center'}
                , {field: 'recommendCode', title: '父级邀请码', minWidth: '100', align: 'center'}
            ]]
            , id: 'dataCheck'
            , url: [[${basePath}]] + '/member/recommendCodeList'
            , method: 'get'
            , page: true
            , limits: [10, 30, 60, 90, 150, 300]
            , toolbar: '#topOperate'
            , limit: 10 //默认采用0
            , loading: true
            // , where: getJson()
            , done: function (res, curr, count) {
                //如果是异步请求数据方式，res即为你接口返回的信息。
                //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                $("td[data-field='content']").each(function () {
                    $(this).find(".layui-table-cell").removeClass('layui-table-cell');
                });
                // 查看登录IP
                $(".loginIP").on("click", function () {
                    var ss = $(this).next().css("display");
                    console.log(ss)
                    if (ss == "none") {
                        $(this).next().css("display", "");
                        $(this).text("隐藏最近登录IP");
                    } else {
                        $(this).next().css("display", "none");
                        $(this).text("显示最近登录IP");
                    }
                })


            }
        });

        //头工具栏事件
        table.on('toolbar(event)', function (obj) {});
        table.on('tool(event)', function (obj) {});


        var status = 0;
        form.on('switch(status)', function (data) {
            if (!data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }

            $("#search").click();

        });

        $("#search").click(function () {
            tableIns.reload({
                where: {
                    recommendCode: $("input[name='recommendCode']").val()
                },
                page: {
                    curr: 1
                }
            });
        })

        function getJson() {
            return {
                where: {
                    recommendCode: $("input[name='recommendCode']").val()
                }
            };
        }
    });
</script>
<!-- 表格操作按钮集 -->
<script type="text/html" id="barOption">
</script>
</body>
</html>